<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
    String path = request.getContextPath();

    String basePath = request.getScheme() + "://" + request.getServerName() + ":"
                      + request.getServerPort() + path + "/";
    //<script type="text/javascript"
	//src="/js/easyui/jquery-1.7.2.min.js"></script>
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>新增角色</title>
<s:include value="../include.jsp"></s:include>
<link rel="stylesheet" type="text/css" href="../css/ztree/demo.css">
<link rel="stylesheet" type="text/css"
	href="<%=basePath%>css/ztree/zTreeStyle/zTreeStyle.css">
<script type="text/javascript"
	src="<%=basePath%>js/ztree/jquery.ztree.core-3.3.js"></script>

<script type="text/javascript">	


	/**
	 * 保存
	 */
	function save() {
		//检验
		var lName = document.getElementById("roleName").value;
		lName = trimVal(lName);
		if (lName == "") {
			alert("角色名是必填项");
			return;
		}
		var lmemo = document.getElementById("memo").value;
		lmemo = trimVal(lmemo);
		if (lmemo == "") {
			alert("角色描述是必填项");
			return;
		}
		var cars = document.getElementById("right");
		if(cars.length<=0){
			alert("请至少选择一个权限");
			return;
		}
		
		allch();
		chgAction("roleAction", "save");
		document.forms[0].submit();
	}
	
	function allch(){
		var cars = document.getElementById("right");
		for (var i = 0; i < cars.length; i++) {
			cars[i].selected = true;
		}
	}
	
	function move(a,b)
	{	
		var s=document.getElementById(a);
		var t=document.getElementById(b);
		for(var i=0;i<s.length;i++)
		{
		 	if(s[i].selected)
		 	{
		    	var op=new Option(s[i].text);
		    	op.value=s[i].value;
		    	s.remove(i);
		    	t.add(op);
				i--;
		  	}
		}
	}
	

	/**
	 * 返回
	 */
	function back() {
		window.location = "roleAction.action";
	}
	<s:if test="operateResult=='suc'">
	alert("保存成功");
	window.location = "roleAction!query.action";
	</s:if>
	<s:elseif test="operateResult=='fail'">
	alert("保存失败");
	</s:elseif>
</script>
</head>
<body>
	<div class="outerDiv" style="height:500px;overflow-y: auto;">
		<s:form name="form1" action="roleAction" method="post">
			<div class="top_box">
				您的位置：系统角色管理&gt;&gt;<span class="red">新增角色</span>
			</div>
			
			<div class="form_list_box">
				<table width="100%">
					<tr>
						<td align="right" width="40%"><font color="red">*</font>角色名：</td>
						<td align="left"><s:textfield name="role.roleName"
								id="roleName" maxlength="25"></s:textfield>
						</td>
					</tr>
					<tr>
						<td align="right" width="40%"><font color="red">*</font>描&nbsp;&nbsp;&nbsp;&nbsp;述：</td>
						<td align="left"><s:textfield name="role.memo"
								id="memo" maxlength="25"></s:textfield>
						</td>
					</tr>
					<tr>
				        <td align="right" width="40%"><font color="red">*</font>权&nbsp;&nbsp;&nbsp;&nbsp;限：</td>
				        <td align="left">
				        	<table width="286" border="0">
						        <tr>
						          <td width="70" rowspan="4"><select name="select" size="15" id="left" multiple style="width: 100px">
						          	<s:iterator value="limitList" id="limitList" status="st">
							        <option value="<s:property value="limitId" />"><s:property value="memo" /></option>
							        </s:iterator>
						          </select></td>
						          <td width="95">&nbsp;</td>
						          <td width="107" rowspan="4"><select name="role.popIds" size="15" id="right" multiple style="width: 100px">
						          </select></td>
						        </tr>
						        <tr>
						          <td><input type="button" name="Submit" value="添加 &gt;&gt;" onClick="move('left','right')"></td>
						        </tr>
						        <tr>
						          <td><input type="button" name="Submit" value="&lt;&lt; 删除" onClick="move('right','left')"></td>
						        </tr>
						        <tr>
						          <td>&nbsp;</td>
						        </tr>
				     	  </table>
				      </td>
				    </tr>
				</table>
				<div class="btn_box">
					<a href="#" onclick="save()"><s></s>保存</a> <a href="#"
						onclick="back()"><s></s>返回</a>
				</div>
			</div>
		</s:form>
	</div>
</body>
</html>